;(function() {
		init_parsley();
		$('#push_btn').click(function () {
            $("#myModalTitle").text("选择作用设备");
		    var url = "/admin/windows/pushTv";
            $("#myModalBody").load(url,function(){
                $("#myModal").modal("show");
            });
        });
	   	$("#form-submits").click(function(){
	   		var flag=$('#validate-form').parsley('validate' );
	   		if(flag){
	   			$.post(
	   				"/admin/windows/tvConfigPost",
	   				$("#validate-form").serialize(),
	   				function(data){
			      		if(data.flag){
			      			$("#myModal").modal("hide");
			      			toastr['success']("操作成功！", ''); 
			      			location.reload();
			      		}else{
			      		 	toastr['error'](data.msg,"操作失败！"); 
			      		}
	   				}
	   			);
	   		}
	   	});
    $('#bg_fileInput').filer({
        changeInput: window.filer_default_opts.changeInput2,
        showThumbs: true,
        limit: 1,
        maxSize: 10,
        extensions:['jpg', 'png', 'jpeg'],
        theme: "dragdropbox",
        templates: window.filer_default_opts.templates,
        dragDrop: window.filer_default_opts.dragDrop,
        uploadFile: {
            url: "/admin/UploaderFile/uploadFile",
            data: {},
            type: 'POST',
            enctype: 'multipart/form-data',
            beforeSend: function(){},
            success: function(data, el){
                var parent = el.find(".jFiler-jProgressBar").parent();
                el.find(".jFiler-jProgressBar").fadeOut("slow", function(){
                    $("<div class=\"jFiler-item-others text-success\"><i class=\"icon-jfi-check-circle\"></i> Success</div>").hide().appendTo(parent).fadeIn("slow");
                });
                $("#bg_image").val(data);
            },
            error: function(el){
                var parent = el.find(".jFiler-jProgressBar").parent();
                el.find(".jFiler-jProgressBar").fadeOut("slow", function(){
                    $("<div class=\"jFiler-item-others text-error\"><i class=\"icon-jfi-minus-circle\"></i> Error</div>").hide().appendTo(parent).fadeIn("slow");
                });
            },
            statusCode: null,
            onProgress: null,
            onComplete: null
        },
        // onRemove: function(itemEl, file, id, listEl, boxEl, newInputEl, inputEl){
        //     var file = file.name;
        //     $.post('/admin/UploaderFile/deleteFile', {file: file});
        // },
        captions:window.filer_default_opts.captions,
    });
    $('#logo_fileInput').filer({
        changeInput: window.filer_default_opts.changeInput2,
        showThumbs: true,
        limit: 1,
        maxSize: 10,
        extensions:['jpg', 'png', 'jpeg'],
        theme: "dragdropbox",
        templates: window.filer_default_opts.templates,
        dragDrop: window.filer_default_opts.dragDrop,
        uploadFile: {
            url: "/admin/UploaderFile/uploadFile",
            data: {},
            type: 'POST',
            enctype: 'multipart/form-data',
            beforeSend: function(){},
            success: function(data, el){
                var parent = el.find(".jFiler-jProgressBar").parent();
                el.find(".jFiler-jProgressBar").fadeOut("slow", function(){
                    $("<div class=\"jFiler-item-others text-success\"><i class=\"icon-jfi-check-circle\"></i> Success</div>").hide().appendTo(parent).fadeIn("slow");
                });
                $("#logo_image").val(data);
            },
            error: function(el){
                var parent = el.find(".jFiler-jProgressBar").parent();
                el.find(".jFiler-jProgressBar").fadeOut("slow", function(){
                    $("<div class=\"jFiler-item-others text-error\"><i class=\"icon-jfi-minus-circle\"></i> Error</div>").hide().appendTo(parent).fadeIn("slow");
                });
            },
            statusCode: null,
            onProgress: null,
            onComplete: null
        },
        // onRemove: function(itemEl, file, id, listEl, boxEl, newInputEl, inputEl){
        //     var file = file.name;
        //     $.post('/admin/UploaderFile/deleteFile', {file: file});
        // },
        captions:window.filer_default_opts.captions,
    });
})();